package cn.fjw.webservice;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * Created by 家玮 on 2014/3/26.
 */
public class DataSource {
    private Connection connection;

    public DataSource() {
        try {
            Class.forName("org.h2.Driver").newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        String url ="jdbc:h2:~/test";
        //myDB为数据库名
        try {
            this.setConnection(DriverManager.getConnection(url));
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
    public Connection getConnection(){
        return this.connection;
    }

    public void setConnection(Connection connection){
        this.connection=connection;
    }
}
